package com.zbf.lock;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/17  15:46
 * 描述:
 */
public class TestThread1 extends Thread {

    ReentrantLock reentrantLock;

    public TestThread1(ReentrantLock reentrantLock) {
         this.reentrantLock=reentrantLock;
    }

    @Override
    public void run() {

          reentrantLock.lock();
           try{

               for (int i=0;i<10;i++){
                   System.out.println(i+"============="+currentThread().getId());
               }

           }catch (Exception e){
               e.printStackTrace();
           }finally {
            reentrantLock.unlock();
        }
    }
}
